import 'package:blue_plugin_example/base/get_common_view.dart';
import 'package:blue_plugin_example/controller/plug_route_xuetang_controller.dart';
import 'package:blue_plugin_example/res/colors.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';

//插件路由
class PlugRouteXT extends GetCommonView<PlugRouteXTController> {
  PlugRouteXT({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    Color textColor = ColorStyle.theme_text_color;
    TextEditingController _xtController = TextEditingController();
    _xtController.text = controller.xtEdit;

    return Scaffold(
      // resizeToAvoidBottomInset: false,
        appBar: AppBar(
            title: const Text("血糖协议连接蓝牙"),
            backgroundColor: ColorStyle.theme_text_color,
            leading: IconButton(
              icon: const Icon(Icons.arrow_back_ios, color: Colors.white,),
              onPressed: () =>
              {
                controller.destroyBlue(),
                Navigator.pop(context)
              }, // NavigatorUtil.back(),
            )
        ),
        body: SingleChildScrollView(
          child: Column(
            children: [
              //血糖布局
              Row(
                mainAxisAlignment: MainAxisAlignment.center,
                crossAxisAlignment: CrossAxisAlignment.center,
                children: [
                  Container(
                    alignment: Alignment.center,
                    width: 170,
                    margin: const EdgeInsets.only(top: 10),
                    child: Stack(
                      alignment: Alignment.center,
                      children: [
                        const Image(
                            image:
                            AssetImage("assets/images/1.0x/xietangyi.png")),
                        //时间
                        Positioned(
                            top: 100,
                            child: Text(
                              controller.time,
                              style: const TextStyle(
                                  fontFamily: 'LESLIEB',
                                  color: ColorStyle.text_color_1E1F20,
                                  fontSize: 16),
                            )),
                        //血糖
                        Positioned(
                            top: 136,
                            right: 30,
                            child: Text(
                              controller.xt,
                              style: const TextStyle(
                                  fontFamily: 'LESLIEB',
                                  color: ColorStyle.text_color_1E1F20,
                                  fontSize: 38),
                            )),

                        //连接按钮背景
                        Positioned(
                            bottom: 20,
                            child: Container(
                              width: 85,
                              height: 38,
                              child: InkWell(
                                child: const Image(
                                  image: AssetImage(
                                      "assets/images/1.0x/btnblue.png"),
                                ),
                                onTap: () => controller.onConnectBtn(),
                              ),
                            )),

                        //连接按钮的文字
                        Positioned(
                            bottom: 20,
                            child: Container(
                              alignment: Alignment.center,
                                width: 85,
                                height: 38,
                                child: InkWell(
                                  child: Text(
                                    controller.connectMsg,
                                    style: TextStyle(color: textColor),
                                  ),
                                  onTap: () => controller.onConnectBtn(),
                                ),
                            )
                        ),
                      ],
                    ),
                  )
                ],
              ),
              //单选按钮
              Container(
                margin: const EdgeInsets.only(top: 10.0),
                decoration: const BoxDecoration(
                ),
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.center,
                  crossAxisAlignment: CrossAxisAlignment.center,
                  children: [
                    Flexible(flex: 1, child: Column()),
                    Flexible(
                      flex: 6,
                      child: RadioListTile(
                        title: const Text('空腹血糖'),
                        value: '空腹血糖',
                        activeColor: ColorStyle.color_btn_bg,
                        groupValue: controller.radioGroupValue,
                        onChanged: (value) {
                          controller.onRadioClick(value);
                        },
                      ),
                    ),
                    Flexible(
                        flex: 6,
                        child: RadioListTile(
                          title: const Text('餐后血糖'),
                          value: '餐后血糖',
                          activeColor: ColorStyle.color_btn_bg,
                          groupValue: controller.radioGroupValue,
                          onChanged: (value) {
                            controller.onRadioClick(value);
                          },
                        )),
                    Flexible(flex: 1, child: Column()),
                  ],
                ),
              ),
              //中间部分
              Container(
                margin: const EdgeInsets.only(top: 10.0),
                padding: const EdgeInsets.only(
                    left: 26, right: 26, top: 16, bottom: 14),
                decoration: const BoxDecoration(
                  color: ColorStyle.color_white,
                ),
                child: Column(
                  children: [
                    // 提示文案模块
                    Container(
                        child: Row(
                          children: [
                            // 占位
                            Flexible(
                                fit: FlexFit.tight,
                                flex: 1,
                                child: Column(
                                  // children: const [
                                  //   Text.rich(TextSpan(children: [
                                  //     TextSpan(
                                  //         text: "收缩压",
                                  //         style: TextStyle(
                                  //             fontSize: 20,
                                  //             color: ColorStyle.text_color_1E1F20)),
                                  //     TextSpan(
                                  //       text: "*",
                                  //       style: TextStyle(
                                  //           fontSize: 18, color: Colors.red),
                                  //     ),
                                  //     TextSpan(
                                  //       text: "\nmmHg",
                                  //       style: TextStyle(
                                  //           fontSize: 15,
                                  //           color: ColorStyle.text_color_1E1F20_45),
                                  //     ),
                                  //   ])),
                                  // ],
                                )),
                            //空腹血糖
                            Flexible(
                                fit: FlexFit.tight,
                                flex: 1,
                                child: Column(
                                  children: [
                                    Text.rich(TextSpan(children: [
                                      TextSpan(
                                          text: controller.radioGroupValue,
                                          style: const TextStyle(
                                              fontSize: 20,
                                              color: ColorStyle
                                                  .text_color_1E1F20)),
                                      const TextSpan(
                                        text: "*",
                                        style: TextStyle(
                                            fontSize: 18, color: Colors.red),
                                      ),
                                      const TextSpan(
                                        text: "\nmmHg",
                                        style: TextStyle(
                                            fontSize: 15,
                                            color: ColorStyle
                                                .text_color_1E1F20_45),
                                      ),
                                    ])),
                                  ],
                                )),
                            //占位
                            Flexible(
                                fit: FlexFit.tight, flex: 1, child: Column()),
                          ],
                        )),
                    //输入框
                    Container(
                        margin: const EdgeInsets.only(top: 10.0),
                        height: 48,
                        child: Row(
                          children: [
                            //占位
                            Flexible(
                                fit: FlexFit.tight,
                                flex: 1,
                                child: Container(
                                  margin: const EdgeInsets.only(left: 10),
                                )),
                            //血糖输入
                            Flexible(
                                fit: FlexFit.tight,
                                flex: 1,
                                child: Container(
                                  margin: const EdgeInsets.only(left: 10),
                                  child: TextField(
                                    controller: _xtController,
                                    style: const TextStyle(fontSize: 18),
                                    keyboardType: TextInputType.number,
                                    textAlign: TextAlign.center,
                                    decoration: const InputDecoration(
                                        contentPadding: EdgeInsets.only(
                                            top: 0, bottom: 0, left: 4),
                                        border: OutlineInputBorder(),
                                        hintText: "请输入",
                                        hintMaxLines: 1,
                                        labelStyle: TextStyle(
                                            color: ColorStyle
                                                .text_color_1E1F20_45)),
                                  ),
                                )),
                            //占位
                            Flexible(
                                fit: FlexFit.tight,
                                flex: 1,
                                child: Container(
                                  margin: const EdgeInsets.only(left: 10),
                                )),
                          ],
                        )),
                  ],
                ),
              ),
              const SizedBox(
                height: 100,
              ),
              //底部按钮
              GestureDetector(
                child: Container(
                  height: 48,
                  alignment: Alignment.center,
                  decoration: BoxDecoration(
                    color: controller.btnColor,
                    //设置四周圆角 角度
                    borderRadius: const BorderRadius.all(Radius.circular(8.0)),
//                      设置四周边框
                    // border: new Border.all(width: 1, color: ColorStyle.theme_text_color),
                  ),
                  margin:
                  const EdgeInsets.only(left: 12, right: 12, bottom: 30),
                  child: const Text("提交",
                      style: TextStyle(
                          color: ColorStyle.color_white, fontSize: 16)),
                ),
                onTap: () => controller.onUpDataBtn(),
              ),
            ],
          ),
        ));
  }
}
